from datetime import datetime
from flask import Blueprint,jsonify
import json

# 创建蓝图
bp_user = Blueprint(__name__,'user')

from data import get_data
from db import db1


# 接口
@bp_user.route('/studentM',methods=['POST'])
def studentM():
    # 获取数据
    data = get_data()
    # sql语句添加到数据库
    sql = """insert into student(name,age,fenshu) values('%s','%d','%d')"""%(data['name'],int(data['age']),int(data['fenshu']))
    sql1 = """select * from student"""
    db1.fingall(sql1)
    if not data['name']:
        return jsonify({'code':20010,'mes':'用户名不能为空'})
    else:        
        # 添加
        db1.intsert(sql)
        # 返回
        return jsonify({'code':200})

@bp_user.route('/stu_login',methods=['POST'])
def stu_login():
    pass
